package com.transport.analysis.traffic;

import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;

public class RouteIdGroupingComparator extends WritableComparator {

    public RouteIdGroupingComparator() {
        super(RouteStopPairWritable.class, true);
    }

    @Override
    public int compare(WritableComparable a, WritableComparable b) {
        RouteStopPairWritable key1 = (RouteStopPairWritable) a;
        RouteStopPairWritable key2 = (RouteStopPairWritable) b;

        // Only compare routeId for grouping
        return Integer.compare(key1.getRouteId(), key2.getRouteId());
    }
}